package com.shuoyue.ycgk.ui.account.login;

import android.app.Activity;
import android.content.Context;
import android.widget.Toast;

import com.umeng.socialize.UMAuthListener;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.utils.SocializeUtils;

import java.util.Map;

public class WeChatLogin {
    public static void login(Activity mContext, WeChatLoginSuc weChatLoginSuc) {
        UMShareAPI.get(mContext).doOauthVerify(mContext, SHARE_MEDIA.WEIXIN,
                new UMAuthListener() {
                    @Override
                    public void onStart(SHARE_MEDIA platform) {
                    }

                    @Override
                    public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
                        weChatLoginSuc.loginSuc(data.get("openid"), data.get("access_token"));
                    }

                    @Override
                    public void onError(SHARE_MEDIA platform, int action, Throwable t) {
                        Toast.makeText(mContext, "失败失败", Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void onCancel(SHARE_MEDIA platform, int action) {
                        Toast.makeText(mContext, "您已取消登录", Toast.LENGTH_LONG).show();
                    }
                });

    }

    public interface WeChatLoginSuc {
        void loginSuc(String openId, String accesstoken);
    }


}

class WxLoginEntity {

}